﻿using IRepository.SystemDefault;
using Model.SystemDefault;
using System;
using System.Collections.Generic;
using System.Text;
using Dapper;
using ModelCache;
using System.Linq;

namespace Repository.SystemDefault
{
    public class CollectorUrlRepository : BaseRepository<CollectorUrlModel>, ICollectorUrlRepository
    {
        public CollectorUrlModel GetExistUrlInfo(int configId, string url, string constr)
        {
            using (var con = GetDbConnection(constr))
            {
                var sql = string.Format("{0} where CollectorConfigID=@CollectorConfigID and Url=@Url order by {1} desc", ModelCache<CollectorUrlModel>._GetAllSql, ModelCache<CollectorUrlModel>._PrimaryKey);
                return con.Query<CollectorUrlModel>(sql, new { CollectorConfigID = configId, Url = url }).FirstOrDefault();
            }
        }
    }
}
